% --- fmanmacs.tex ---

% --- MACROS for the FWEB USER'S MANUAL and INSTALLATION GUIDE ---

% These are included both into fwebman.tex and INSTALL_FWEB.tex.

% FWEB version 1.30 (June 10, 1993)

%---------------------------------------------------------------------------

% We'll use some of the FWEB macros.
\let\outer\relax
\input fwebmac.sty

\font\bigbf=cmbx10 scaled\magstep2
\font\tenss=cmss10 \let\ss\tenss
\font\tenssbf=cmssbx10 \let\ssbf\tenssbf

\def\topofcontents{\centerline{\titlefont\Wtitle}
	\bigskip
	\centerline{\bigbf Version \FWEBversion}
	\medskip
	\centerline{\bigbf \FWEBdate}
	\vfill}

\def\botofcontents{\vfill}

\newif\ifbilevel
% For indenting of original authors' contributions, use the next statement:
% \bileveltrue

\def\KNUTH{\begingroup\indenttext}
\def\Knuth{\begingroup\ifbilevel\indenttext\fi}
\def\indenttext{\leftskip=0.5truein\rightskip=\leftskip}
\def\endKnuth{\par\endgroup}
\let\endKNUTH\endKnuth

\def\[{\ifbilevel[\fi}
\def\]{\ifbilevel]\fi}
\def\Levy#1{\ifbilevel{\sl [Levy]#1}\fi}
\def\bdots{\ifbilevel\dots\else\unskip\ignorespaces\fi}

% --- REFERENCES ---
\input fmanrefs

% --- PAGE OUTPUT ---
\newcount\Contentspageno
\Contentspageno=1

\newcount\pagecount
\newcount\pagestart

\countdef\pageno=1
\countdef\Pageno=0

\pagestart=\PAGESTART
\Pageno=\pagestart % We have a long table of contents.
\pagecount=\Pageno

\def\PAGENO{\the\pagecount}

\newif\iftypesetting
\newif\ifstarttypesetting
\newif\ifdonetypesetting

\def\normaloutput#1#2#3{
	\ifodd\Pageno\hoffset=\pageshift\fi
	\shipout\vbox{
	\vbox to\fullpageheight{
	\iftitle\global\titlefalse
	\else\hbox to\pagewidth{\vbox to10pt{}%
        \ifodd\Pageno #3%---Page heads alternate left and right.
                % #2% --Make all the page heads identical.
        \else#2\fi
        }\fi
\vskip10pt minus 5pt
#1\vfill}} % Parameter #1 is the page itself
%\showthe\Pageno
\global\advance\Pageno by1
\global\pagecount=\Pageno
\global\advance\pagecount by-\Contentspageno
\global\advance\pagecount by1
%\showthe\pagecount
}

\overfullrule=0pt

% --- MISCELLANEOUS STUFF FOR THE TEXT ---

\catcode`\@=11
\font\fourteenr = cmr10 scaled \magstep2
\font\fourteenss = cmss10 scaled \magstep2
\font\fourteenti = cmti10 scaled \magstep2
\font\fourteenbx = cmbx10 scaled \magstep2
\font\fourteenbxti = cmbxti10 scaled \magstep2
\font\fourteenssbx = cmssbx10 scaled \magstep2

\def\fourteenpoint{\def\rm{\fam0\fourteenr}%
\comment
  \textfont0=\fourteenr \scriptfont0=\twelver \scriptscriptfont0=\tenr
  \textfont1=\fourteeni \scriptfont1=\twelvei \scriptscriptfont1=\teni
  \textfont2=\fourteensy \scriptfont2=\twelvesy \scriptscriptfont2=\tensy
  \textfont3=\tenex \scriptfont3=\tenex \scriptscriptfont3=\tenex
\endcomment
%
  \def\it{\fam\itfam\fourteenti}%
  \textfont\itfam=\fourteenti
%
  \def\bfit{\fourteenbxti}%
%
  \def\ss{\fourteenss}%
  \def\ssbf{\fourteenssbx}%
%
  \def\bf{\fam\bffam\fourteenbx}%
\comment
  \textfont\bffam=\fourteenbx \scriptfont\bffam=\twelvebx
 	  \scriptscriptfont\bffam=\tenbf
\endcomment
%
  \normalbaselineskip=12pt \normalbaselineskip=1.4\normalbaselineskip
  \setbox\strutbox=\hbox{\vrule height8.5pt depth3.5pt width\z@}%
  \normalbaselines\rm}
\catcode`\@=12

% --- \parinsert:  Insert larger text in a cutout box.
\def\goodbreak{\par\penalty-2500}

\newcount\num
\newdimen\wsize
\newdimen\lsize

% #1 --- # of lines before insertion.
% #2 --- # of lines of insertion.
% #3 --- width of insertion is #3\hsize.
% #4 --- text of insertion.
\def\parinsert#1#2#3#4\par{\goodbreak\parinserto{#1}{#2}{#3}{#4}\par}

\def\parinserto#1#2#3#4\par{%
\wsize=#3\hsize % Width of insertion.
\lsize=\hsize \advance\lsize by-\wsize % Width of line minus insertion.
\num=#1 \advance\num by#2 % Total number of line to end of insertion.
% Generate #1 full lines at beginning of paragraph.
\let\A\empty
\loop\ifnum\num>#2 \advance\num by-1
	\edef\A{0pt \hsize \A}%
\repeat
% Generate #2 lines of insertion.
%\ifodd\Pageno\advance\lsize by\leftskip\fi
\let\B\empty
\loop\ifnum\num>0 \advance\num by -1
	\ifodd\Pageno
		\edef\B{0pt \lsize \B}% Insertion on right-hand boundary.
	\else
		\edef\B{\wsize \lsize \B}% Insertion on left-hand boundary.
	\fi
\repeat
\num=#1 \advance\num by#2 \advance\num by1
\edef\next{\parshape\the\num\space\A\B 0pt \hsize}
\next % The actual paragraph shape.
\num=#1 \advance\num by-1
\leavevmode\vbox to0pt{\hbox{\lower\the\num.25\baselineskip\hbox to0pt{\vtop
to0pt{\ifodd\Pageno\advance\lsize by-2\leftskip
\moveright\lsize\else\moveleft\parindent\fi
\vtop to#2\baselineskip
{\vss\vtop{\hsize=\wsize \advance\hsize by-\parindent
%\ifodd\Pageno\advance\hsize by-\leftskip\fi %\advance\hsize by-\rightskip
\leftskip=0pt \rightskip=0pt
\tolerance5000
\let\tt\ttitlefont
\fourteenpoint\bf\noindent \ignorespaces#4}\vss}\vss}\hss}}\vss}}

\def\Mathop#1{\mathop{\rm #1}\nolimits}

\def\Dv{\Delta v}

\def\KP{Kernighan and Plauger}
\def\Identifier{{\it identifier}}
\def\Replacementtext{{\it replacement-text}}
\def\Optcmnt{{\it [optional C-style comment]}}
\def\Arglist{{\it argument-list}}
\def\cond{{\it condition}}
\def\expr{{\it expression}}

\def\atcmd#1{\hbox{`\.{@#1}'}}
\def\Item{\item{$\bullet$}}
\def\hl#1{{\bf #1}} % Highlight
\def\stmt{\{\dots\}}
\def\truetext{true\_text}
\def\falsetext{false\_text}
\def\Stringize{\.{\#}}
\def\paste{\#\#}
\def\Paste{\.{\paste}}

\def\clo#1{$$\vtop{\halign{\tt##\hfil&\ ---\ \vtop{\hsize=0.8\hsize
        \noindent\hang\strut##\strut\vskip3pt}\hfil\cr#1}}$$}

\def\lstar{\llap{*\kern2em}}

\def\Bug#1.{\newfeature\noindent{\bf#1}.\nobreak}

% ---SHIFT INTO VERBATIM CODE MODE ---
{\catcode`\^^I=\active
\gdef\codemode{\narrower\narrower
\let\Par\medskip
\def\Stmt{^^I\stmt}
\catcode`\^^I=\active
\def\Tab{\hskip20pt}\let^^I\Tab
\catcode`\#=\other\catcode`\%=\other\catcode`\_=\other\catcode`\&=\other
\let\math$\catcode`\$=\other
\def\\{\char`\\}
\tt\parindent=0pt\parskip=0pt\medskip\obeylines}}

\def\PR{@\#}
\def\If{\.{\PR if}}
\def\Elif{\.{\PR elif}}
\def\Define{\.{\PR define}}
\def\Ifdef{\.{\PR ifdef}}
\def\Ifndef{\.{\PR ifndef}}
\def\Undef{\.{\PR undef}}
\def\Else{\.{\PR else}}
\def\Endif{\.{\PR endif}}

\def\LANBUILTINS{$$\vbox{\offinterlineskip
\halign{\vrule\vrule##&\strut\quad##\quad\hfil&\vrule##&
	\hfil\quad\tt\_##\quad\hfil
	&\vrule##&\hfil##\hfil&\vrule\vrule##\cr
\tablerule\tablerule
&\It{Language}&&\_LANGUAGE&&\quad\tt\_LANGUAGE\_NUM\quad&\cr
\tablerule\tablerule
&C&&C&&0&\cr
&\Cpp&&CPP&&1&\cr
&\Fortran--77&&N&&2&\cr
&\Fortran--90&&N90&&3&\cr
&\Ratfor--77&&R&&4&\cr
&\Ratfor--90&&R90&&5&\cr
&\TeX&&X&&6&\cr
\tablerule\tablerule
}}$$}

% Automatic numbering of features.
\newcount\featurecount
\def\newfeature{\featurecount=0}
\def\Feature#1.{\global\advance\featurecount by 1
  \subsection 
%\the\featurecount: % This didn't look too good.
 #1.\par} 
\def\feature{\global\advance\featurecount by 1 
\leavevmode\llap{\the\featurecount}}

\def\undertext#1{$\underline{\hbox{#1}}$}
\def\medalign{\noalign{\medskip}}
\def\subheading#1{\noalign{\medskip\hbox{\bf#1}\smallskip}}
\def\tablerule{\noalign{\hrule}}

\def\lstar{\llap{*\kern2em}}

\def\It#1{{\it #1}}
\let\IF\Wintrinsic

\def\ttbox#1{\leavevmode\hbox{\tt #1}}
\def\WEAVE{\ttbox{WEAVE}}\def\FWEAVE{\ttbox{FWEAVE}}
\def\TANGLE{\ttbox{TANGLE}}\def\FTANGLE{\ttbox{FTANGLE}}
\def\WEB{\ttbox{WEB}}
\def\CWEB{\ttbox{CWEB}}
\def\FWEB{\ttbox{FWEB}}

\def\Pascal{Pascal}

\def\stylehook#1{\def\subtitle{\noalign{\leftline{\bf #1:}\medskip}}}

\def\style#1#2\par{\filbreak
\stylehook{#1}
$$\def\<##1>{{\bf Default:} {\tt ##1}.\smallskip}
\vtop{\halign{\tt##\quad\hfil&\it##\quad\hfil&%
	\vtop{\hsize0.6\hsize\noindent\hang##}\hfil\cr
	\subtitle#2}}$$}


%\parskip 0pt plus 1pt
\parskip=\pardimen

% --- STUFF FROM THE ORIGINAL MANUAL ---
\def\RA{\char'31 } % right arrow
%\def\hang{\hangindent 4em\ignorespaces}
\font\ninerm=cmr9
\font\ninett=cmtt9
\font\eighttt=cmtt8
\let\mc=\ninerm % medium caps for names like SAIL
\def\PASCAL{Pascal}
\font\quoterm=cmssq8
\font\quoteit=cmssqi8
\def\pb{\.{|...|}}
\def\lpile{\let\"\.\def\.##1{\hbox{\"{##1}}}
        \def\cr{\hfill\endline}\matrix} % I only use \lpile by itself

% ---MANUAL SECTIONS ---
\def\sectionbreak{\penalty-1500\vskip 12pt plus 6pt minus 3pt}

\newcount\sectionnum
\newcount\subsectionnum
\newcount\subsubsectionnum

\def\startsection#1#2#3{\sectionbreak
 \advancesections{#1}%
 \edef\next{\write\cont{\WZ{#1}{\sctnnum}{#3}{\noexpand\PAGENO}}}\next
  \global\def\argone{#1}\global\def\argtwo{#2}\global\def\argthree{#3}%
  \futurelet\next\optarg}

\def\optarg{\ifx\next[\let\next\getopt\else\let\next\dosctn\fi\next}
\def\getopt[#1]{\maxsctn{\argone}{#1}\dosctn}
\def\dosctn#1\par{%
	\leftline{\llap{\argtwo\enspace}\sctnnum\enspace\bf\argthree#1}\nobreak
	\vskip\normalbaselineskip\vskip-\parskip}

\def\advancesections#1{\ifcase#1
		\vskip6pt plus3pt minus3pt
		\global\advance\sectionnum by 1\global\subsectionnum=0
	\or
		\vskip3pt plus1pt minus1pt
		\global\advance\subsectionnum by 1\global\subsubsectionnum=0
	\or
		\vskip2pt plus1pt minus2pt
		\global\advance\subsubsectionnum by 1\fi}

\def\sctnnum{{\ssbf\the\sectionnum.}\ifnum\subsectionnum=0
	\else{\bf\the\subsectionnum}%
		\ifnum\subsubsectionnum=0
		\else{\bf.}{\rm\the\subsubsectionnum}\fi
	\fi}

\def\maxsctn#1#2{\maxsctno{#1}#2.0.0.\relax}
\def\maxsctno#1#2.#3.#4.#5\relax{{\sectionnum=#2 \subsectionnum=#3
		\subsubsectionnum=#4 
	\setbox0=\hbox{\sctnnum}%
      \edef\next{\write\cont{\noexpand\ctswidth{#1}{\the\wd0}}}\next}}
\def\ctswidth#1#2{\ifcase#1\ctsb\or\ctsc\else\ctsa\fi=#2}

% Running headline.
\def\rhead{\ifx\Wname\empty\else
	\ifcase\Wss
		\uppercase{\Wname}%
	\else
		\Wname%
	\fi\fi}% Define running headline.

\def\Mark#1{\edef\Wname{#1}\Wmark}
\def\modno{0}

\def\SS#1#2#3{\Wss=#1\Mark{#3}\startsection#1{#2}{#3}}

\outer\def\section #1.{\SS0{}{\ssbf#1}}
\outer\def\dsection #1.{\SS0{\dbend}{\ssbf#1}}
\outer\def\ddsection #1.{\SS0{\dbend\dbend}{\ssbf#1}}

\outer\def\subsection #1.{\SS1{}{#1}}
\outer\def\dsubsection #1.{\SS1{\dbend}{#1}}
\outer\def\ddsubsection #1.{\SS1{\dbend\dbend}{#1}}

\outer\def\subsubsection #1.{\SS2{}{\rm{#1}}}
\outer\def\dsubsubsection #1.{\SS2{\dbend}{\rm{#1}}}
\outer\def\ddsubsubsection #1.{\SS2{\dbend\dbend}{\rm{#1}}}

\font\manual=manfnt
\def\dbend{$\clubsuit$}

\outer\def\appendix#1:#2.[#3]{\def\next{#3}%
        \ifx\next\empty
                \Mark{APPENDIX~#1: #2}
        \else
                \Mark{APPENDIX~#1: #3}
        \fi
        \startsection1{}{APPENDIX #1: #2}}

\def\Eject{\Mark{}\eject}

\def\Wtitlepage{T}

\def\Whead{\expandafter\iffalse\topmark\fi}

\def\enext{\edef\next{\Whead}\edef\next{\next}}

\def\lheader{\ifnum\pagecount<2\hfill\else
	\enext
        \mainfont\PAGENO\hfill\ifx\next\empty\else\SC--- \next\
		\SC---\fi\hfill\fi} 
\def\rheader{\ifnum\pagecount<2\hfill\else
	\enext
	\hfill\ifx\next\empty\else\SC--- \next\ \SC---\fi\hfill
		\mainfont\PAGENO\fi}
\def\runninghead{{\tentt FWEB} USER MANUAL (v.~\version)}

% --- VERBATIM MODE ---
% This verbatim mode assumes that no ? appears in the text being copied. It
% takes an optional file name as argument. If that's not empty, then text is
% input from that file.
\def\verbatim#1{\begingroup
  \def\next{#1}%
  \ifx\next\empty
        \let\Input\relax
   \else
          \def\Input{\input #1\^^M\endgroup}%
   \fi
  \def\do##1{\catcode`##1=12 } \dospecials
  \parskip 0pt \parindent 0pt
  \catcode`\ =13 \catcode`\^^I=13 \catcode`\^^M=13
  \tt \let\question?\catcode`\?=0 \let\?\question
        \verbatimdefs \verbatimgobble}

{\catcode`\ =13 \catcode`\^^I=13 \catcode`\^^M=13 %
  \gdef\verbatimdefs{\def^^M{\ \par}\let =\ \def^^I{\noindent\kern30pt}} %
  \gdef\verbatimgobble#1^^M{\Input}}

% --- TYPESET OUTPUT FROM FWEAVE ---
\def\HRULE{\medbreak\hrule\medbreak}

\long\def\typeset#1{%
{ % Make certain operations local; kill off some others.
\def\Wbegin[##1]##2##3##4##5##6{}

\let\@\IF
\def\Eject{\medskip\eject}

\def\eject{\noindent\It{(Page break skipped.)}\par}

\def\startsection{\WQ\noindent{\let\*=\lapstar\bf\modstar.%
\ifx\includefile\empty\else\ [{\tt\includefile}]\fi\quad}}

\def\Wsectionbreak{\ifcase\Wss\bigskip\fi}

\def\WNss{\Wsectionbreak
  \ifon
	\ifcase\Wss\else\Wskip\fi
	\startsection{\bf\ignorespaces\Wname.\quad}\ignorespaces}

\outer\def\MN##1.{\par % Common code for \WM, \WN
  \parskip=\pardimen % Reset to TeX spacing
  {\xdef\modstar{##1}\let\*=\empty\xdef\modno{##1}}
  \ifx\modno\modstar \onmaybe \else\ontrue \fi \Mark{}}

\def\Winx{\endinput\bigskip\noindent\It{(Index and remaining material
skipped.)}\Eject}
\let\Wmods\endinput % Skip the module list.
\long\def\Winfo##1\Wcon{\endinput} % Skip the info and table of contents.

\input #1.tex % Actually read in the tex code.
}\global\pageno=0}


%                       *       *       *


\input indexing % This is for creating the index.

\def\>#1{#1:\noexpand\.{#1}} % Index entry in typewriter type.
\def\=#1#2{#1:\noexpand\.{#2}} % Generalization of above.
\def\CS#1{#1:\noexpand\.{\BS#1}} % Control sequence.
\def\<#1{#1:\noexpand\&{#1}} % Index entry in bold type.

\def\DOT#1#2#3{^^{\>{.#1.}} ^^{\>{#2}} ^^{$#3$}}

\def\actual{:}

\def\TEX{\noexpand\TeX}
\def\LATEX{\noexpand\LaTeX}
\def\FORTRAN{\noexpand\Fortran}
\def\RATFOR{\noexpand\Ratfor}

\def\startcontents{\openout\cont=\contentsfile}
\def\readcontents{\input\contentsfile}

\newdimen\ctsa \newdimen\ctsb \newdimen\ctsc \newdimen\ctsskip
\ctsa=0pt \ctsb=0pt \ctsc=0pt

\def\Wcon{\par\vfill\eject % FINISH the table of contents.
   \immediate\closeout\cont
  \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  \setpage
  \Mark{Table of contents}
  \output{\normaloutput\page\lheader\rheader}
  \titletrue % Prepare to output the table of contents
% The following trickery is to make the page number of the table of
% contents equal to the last page number of the manual. In fact, the page
% number isn't printed for the table of contents, but this scheme allows
% makeindex to use the "-p any" option to hunt backwards through the
% fwebman.log file to find that page number, so it can start the index at
% the appropriate page.
\Contentspageno=\Pageno
\advance\Contentspageno by-\pagestart
\advance\Contentspageno by 1
  \Pageno=\Contentspageno 
  \def\rhead{TABLE OF CONTENTS}
  \message{Table of contents:}
  \topofcontents
  \catcode`\@=11
  \line{\hfil Page}
  \def\WZ##1##2##3##4{\ifcase##1 \medskip\or\smallskip\fi
\line{\kern##1em
	\ifcase##1\let\ctsskip\ctsa \ctsb=0pt
		\or\let\ctsskip\ctsb \ctsc=0pt
		\or\let\ctsskip\ctsc\fi
	\kern\ctsskip\llap{\hbox to\ctsskip{##2\hfil}}\enspace
    {\ifcase##1 \ssbf\or\bf\fi ##3}%
    \leaders\hbox to .5em{.\hfil}\hfil\ ##4}}
  \readcontents\relax % Read the contents info
  \botofcontents 
\end} % Print the contents page(s) and terminate

\startcontents

\def\doctitle#1{{\titlefont
\centerline{The {\ttitlefont WEB} System of Structured}
\centerline{Software Design and Documentation}
\centerline{for C, C{\ttitlefont++}, Fortran, Ratfor, and \TeX}
\medskip
\centerline{#1}
\smallskip
}
\bigskip
\centerline{\bf JOHN A. KROMMES}
\smallskip
\centerline{\bfit Princeton University}
\smallskip
\centerline{\tt krommes@princeton.edu}
\medskip
\centerline{\tt FWEB \rm Version \FWEBversion}
\centerline{\FWEBdate}
}